import django_filters
from apps.HttpTestcase.models import Testsuite


class TestsuiteNamesFilters(django_filters.rest_framework.FilterSet):
    project = django_filters.CharFilter(field_name='project', lookup_expr='exact')

    class Meta:
        model = Testsuite
        fields = ['project']


class TestsuiteFilters(django_filters.rest_framework.FilterSet):
    # iexact表示精确匹配, 并且忽略大小写
    # icontains表示模糊查询（包含），并且忽略大小写
    # exact表示精确匹配

    name = django_filters.CharFilter(field_name='name', lookup_expr='icontains')
    project = django_filters.CharFilter(field_name='project_id', lookup_expr='exact')
    level = django_filters.CharFilter(field_name='level', lookup_expr='exact')


    class Meta:
        model = Testsuite
        fields = ['name', 'project', 'level']
